<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("UTF-8");
	response.setContentType("text/html;charset=UTF-8");
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String path = request.getContextPath();
%>
<html lang="zh-cn">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>  
    <link rel="stylesheet" href="<%=path %>/admin/css/pintuer.css">
    <link rel="stylesheet" href="<%=path %>/admin/css/admin.css">
    <link rel="stylesheet" href="<%=path %>/admin/css/style.css">
    <link rel="stylesheet" href="<%=path %>/admin/font-awesome-4.7.0/css/font-awesome.css">
    <link rel="stylesheet" href="<%=path %>/static/css/paging.css" />
    <script src="<%=path %>/admin/js/jquery.js"></script>
    <script src="<%=path %>/admin/js/pintuer.js"></script> 
    <script src="<%=path %>/static/js/paging.js"></script>
</head>
<body>
<form method="post" action="<%=path %>/feedback/newPage.html" id="listform">
<input type="hidden" id="totalSize" name="totalSize" value="${count }">
<input type="hidden" id="pageNo" name="pageNo" value="${pageNo}">
<input type="hidden" id="pageSum" name="pageSum" value="${pageSum}">
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder">&nbsp;反馈列表</strong> </div>
    <table class="table table-hover text-center">
      <tr class="thead">
        <th style="text-align:left; padding-left:20px;width:5%">序号</th>
        <th style="width:10%">姓名</th>
        <th style="width:10%">手机号</th>
        <th style="width:10%">提交时间</th>
        <th width="10%">状态</th>
        <th width="10%">操作</th>
      </tr>
      	 <c:forEach items="${BFeedbacks}" var="list" varStatus="vs">
              	<tr class="fir">
		          <td style="text-align:left; padding-left:20px;">${vs.count+pageInfo.startIndex+(pageNo-1)*15}</td>
		          <td>${list.name}</td>
		          <td>${list.phone}</td>
		          <td><fmt:formatDate value="${list.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
               <c:if test="${list.state eq '1'}">
		           <td>待解决</td> 
	           </c:if>
	           <c:if test="${list.state eq '2'}">
                    <td>已受理</td> 
                </c:if>
                <c:if test="${list.state eq '3'}">
                    <td>已解决</td> 
                </c:if>
		          <td>
		              <div class="suspended-pos"><i class="fa fa-folder-open" onclick="update('${list.id}')"></i><span class="suspended">查看</span></div>
		          </td>
		        </tr>	
              </c:forEach>
       <c:if test="${empty BFeedbacks}">
        <tr>
            <td colspan="5" class="t_c">
                <span class="no-records">暂无数据</span>
            </td>
        </tr>
      </c:if>
      <c:if test="${!empty BFeedbacks}"> 
          <tr>
            <td colspan="9">
                <div id="page" class="page_div"></div>
            </td>
          </tr>
      </c:if>
    </table>
  </div>
</form>
<script type="text/javascript" src="<%=path%>/admin/js/layer/layer.js" ></script>
<script type="text/javascript">
var paths = '<%=path %>';
var pageNo = Number($("#pageNo").val());
var totalSize = Number($("#totalSize").val());
var totalPage = Number($("#pageSum").val());
page();
//分页
function page(){
	$("#page").paging({
	    pageNo:pageNo,//当前页
	    totalPage: totalPage,//总页数
	    totalSize: totalSize,//总条数
	    callback: function(num) {
	        newPage(num);   
	    }
	})
}
//搜索
function changesearch(){	
	newPage(1);		
}
//newPage or search
function newPage(pageNo){
	var params = new Object();
	params.pageNo = pageNo;
	$.ajax({ 
		type:"post",
		url:"<%=path %>/feedback/newPage.html",
		data:params,
		dataType: "json",  
        timeout: 10000,  
        cache: false,  
        error: function(){
        	alert("系统忙...");
        },
        success: function(data){
        	var json=eval(data);
        	pageNo = json.pageNo;
        	pageSum = json.pageSum;
        	count = json.count;
        	var htmls = "";
       	 $.each(json.BFeedbacks, function (index, item) {
       		var xu=(pageNo-1)*15+index+1;
               htmls+='<tr class="fir">'
					+'<td style="text-align:left; padding-left:20px;">'+xu+'</td>'
					+'<td>'+item.name+'</td>'
					+'<td>'+item.phone+'</td>'
					+'<td>'+getNowFormatDate(item.createTime)+'</td>'
               if(item.state=="1"){
                   htmls+='<td>待解决</td>';
               }else if(item.state=="2"){
            	   htmls+='<td>已受理</td>';
               }else{
            	   htmls+='<td>已解决</td>';
               }
			    htmls+='<td><div class="suspended-pos"><i class="fa fa-folder-open" onclick="del(\''+item.id+'\')"></i><span class="suspended">查看</span></div>';
				htmls+='</td></tr>';
         });
       	 $(".fir").remove();
       	 $(".thead").after(htmls);
         if(htmls==""){
        	 $("#page").html("");
         }else{
        	 $("#page").html("");
        	 $("#page").paging({
                 pageNo:pageNo,//当前页
                 totalPage: pageSum,//总页数
                 totalSize: count,//总条数
                 callback: function(num) {
                     newPage(num); 
                }
             }) 
          }
        }	
	});
}

function update(id){
	window.location.href="<%=path %>/feedback/detail.html?id="+id;
}	

	
 function getNowFormatDate(time) {
	    var date = new Date(time);
	    var seperator1 = "-";
	    var seperator2 = ":";
	    var year = date.getFullYear();
	    var month = date.getMonth() + 1;
	    var strDate = date.getDate();
	    if (month >= 1 && month <= 9) {
	        month = "0" + month;
	    }
	    if (strDate >= 0 && strDate <= 9) {
	        strDate = "0" + strDate;
	    }
	    var h = 0;
	    if (date.getHours() >= 0 && date.getHours() <= 9) {
	        h = "0" + date.getHours();
	    }else{
	    	h = date.getHours();
	    }
	    var m = 0;
	    if (date.getMinutes() >= 0 && date.getMinutes() <= 9) {
	        m = "0" + date.getMinutes();
	    }else{
	    	m = date.getMinutes();
	    }
	    var s = 0;
	    if (date.getSeconds() >= 0 && date.getSeconds() <= 9) {
	        s = "0" + date.getSeconds();
	    }else{
	    	s = date.getSeconds();
	    }
	    var currentdate = year + seperator1 + month + seperator1 + strDate
	            + " " + h + seperator2 + m
	            + seperator2 + s;
	    return currentdate;
	}
</script>
</body>
</html>